package uk.ljmu.qudexapps.manager.controllers;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.support.RequestContextUtils;

@Controller
public class MainController {
	/**
	 * the SL4J logger instance for this class
	 */
	Logger logger = Logger.getLogger(MainController.class);
	
	@Autowired
	/**
	 * the MessageSource object for internationalised/localised messages
	 */
	MessageSource messageSource;
	
	/***************************************************
	 * URL: /swf-qudex-collections get(): welcome page
	 * 
	 * @param request
	 *            : MultipartHttpServletRequest auto passed
	 * @return welcome view
	 ****************************************************/
	@RequestMapping("/")
	public ModelAndView intro(HttpServletRequest request) {
		// We need to ckeck here whether Fedora and Mulgara are running
		// before allowing for any operation to be performed
		ModelAndView mov = new ModelAndView();
		mov.addObject("locale", RequestContextUtils.getLocale(request));
		mov.setViewName("intro");
		return mov;
	}
	
	/***************************************************
	 * URL: /swf-qudex-collections/intro get(): welcome page
	 * 
	 * @param request
	 *            : MultipartHttpServletRequest auto passed
	 * @return welcome view
	 ****************************************************/
	@RequestMapping("/intro")
	public ModelAndView intro2(HttpServletRequest request) {
		// We need to ckeck here whether Fedora and Mulgara are running
		// before allowing for any operation to be performed
		ModelAndView mov = new ModelAndView();
		mov.addObject("locale", RequestContextUtils.getLocale(request));
		mov.setViewName("intro");
		return mov;
	}
	
	/***************************************************
	 * URL: /swf-qudex-collections/error/defaultError get(): welcome page
	 * 
	 * @param request
	 *            : MultipartHttpServletRequest auto passed
	 * @return defaultError view
	 ****************************************************/
	@RequestMapping("/error/defaultError")
	public ModelAndView error(HttpServletRequest request) {
				
		ModelAndView mov = new ModelAndView();
		mov.addObject("locale", RequestContextUtils.getLocale(request));
		mov.setViewName("error/defaultError");
		return mov;
	}
	
	/***************************************************
	 * URL: /swf-qudex-collections/documentation get(): documentation page
	 * 
	 * @param request
	 *            : MultipartHttpServletRequest auto passed
	 * @return documentation.html view
	 ****************************************************/
	@RequestMapping("/documentation")
	public ModelAndView documentation(HttpServletRequest request) {
		ModelAndView mov = new ModelAndView();
		mov.addObject("locale", RequestContextUtils.getLocale(request));
		mov.setViewName("documentation");
		return mov;
	}
	
	/***************************************************
	 * URL: /swf-qudex-collections/overview get(): documentation page
	 * 
	 * @param request
	 *            : MultipartHttpServletRequest auto passed
	 * @return overview.html view
	 ****************************************************/
	@RequestMapping("/overview")
	public ModelAndView overview(HttpServletRequest request) {
		ModelAndView mov = new ModelAndView();
		mov.addObject("locale", RequestContextUtils.getLocale(request));
		mov.setViewName("overview");
		return mov;
	}
	
	/***************************************************
	 * URL: /swf-qudex-collections/standards get(): documentation page
	 * 
	 * @param request
	 *            : MultipartHttpServletRequest auto passed
	 * @return standards.html view
	 ****************************************************/
	@RequestMapping("/standards")
	public ModelAndView standards(HttpServletRequest request) {
		ModelAndView mov = new ModelAndView();
		mov.addObject("locale", RequestContextUtils.getLocale(request));
		mov.setViewName("standards");
		return mov;
	}
}
